def reverse (s)
{
    return s.inject(' ') { result, c -> c + result }
}

def getInput(prompt)
{
	print prompt
	def input = ' '
	System.in.withReader() { input = it.readLine() }
	return input
}

def stringToReverse = getInput('Enter a message: ')

println reverse(stringToReverse)